//
//  HistorySQLiteManager.h
//  CLBrowser
//
//  Created by 梁慧聪 on 2017/4/6.
//  Copyright © 2021年 梁慧聪. All rights reserved.
//

#import "CLSQLiteManager.h"

typedef void(^HistorySQLiteDeleteCompletion)(BOOL success);

@interface CLHistoryItemModel : NSObject

@property (nonatomic, copy) NSString *hourMinute;
@property (nonatomic, copy) NSString *url;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *time;

+ (CLHistoryItemModel *)historyItemWithHourMinute:(NSString *)hourMinute url:(NSString *)url title:(NSString *)title time:(NSString *)time;

@end

typedef void(^HistoryCompletionHandler)(NSMutableArray<CLHistoryItemModel *> *);
typedef void(^HistoryTodayYesterdayCompletionHandler)(NSMutableArray<CLHistoryItemModel *> *today,NSMutableArray<CLHistoryItemModel *> *yesterday);

@interface CLHistorySQLiteManager : CLSQLiteManager

SYNTHESIZE_SINGLETON_FOR_CLASS_HEADER(CLHistorySQLiteManager)
- (void)insertOrUpdateHistoryWithURL:(NSString *)url title:(NSString *)title;
- (void)getHistoryDataByLimit:(NSInteger)limit offset:(NSInteger)offset handler:(HistoryCompletionHandler)handler;
- (void)getTodayAndYesterdayHistoryDataWithHandler:(HistoryTodayYesterdayCompletionHandler)handler;
- (void)deleteHistoryRecordWithModel:(CLHistoryItemModel *)model completion:(HistorySQLiteDeleteCompletion)completion;
- (void)deleteAllHistoryRecords;

@end
